
function stateChanged()
{
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   {
      if(xmlHttp.responseText=='Successful')
      {
         return true;
      }
      else
      {
         return false
      }
   }
}

function GetXmlHttpObject()
{
	var xmlHttp=null;

	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
	// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function _recatchaGetValidation() {
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }

    var challenge = Recaptcha.get_challenge();
    var response = Recaptcha.get_response();
    var url = "ext_lib/recaptcha_validate.php";

    //xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("POST",url,false);
    xmlHttp.setRequestHeader("content-type", "application/x-www-form-urlencoded");
    xmlHttp.send('recaptcha_challenge_field='+challenge+'&recaptcha_response_field='+response);
    return stateChanged();

}


function recaptchaGetValidation() {

    var recaptcha_verified = _recatchaGetValidation();

    if ( recaptcha_verified == 1 ){
        Recaptcha.destroy();
        return true;
    } else if ( recaptcha_verified == 0 ) {
        Recaptcha.reload();
        recaptcha_verified = -1;
        return false;
    }
}
